﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using System;
using NJamb.NUnit;
using NJamb.Parser.SpecificationBuilders.SubjectIs.Extensions;
using NJamb.Parser.SubjectBuilders;
using NJamb.Specifications.Delta;
using NJamb.Specifications.Simple;
using NUnit.Framework;
using Stile.Patterns.SelfDescribingPredicates;
#endregion

namespace NJamb.Tests.Specifications.Simple
{
    [TestFixture]
    public class SimpleSpecificationExtensionsFixture : EvaluatingSampleFixture
    {
        [Test]
        public void Always()
        {
            // arrange
            IDeltaSpecification deltaSpecification = Specify.For(() => _sample).That(x => x.Bool).Is.False().Always();

            // act
            IPreconditionEvaluation preconditionEvaluation = deltaSpecification.EvaluatePrecondition();

            // assert
            Assert.That(_sample.Bool, Is.False, "precondition");
            IEvaluation before = preconditionEvaluation.Evaluation;
            Assert.That(before.Success, Is.True);

            _sample.Bool = true;
            IEvaluation after = preconditionEvaluation.GetPostcondition().Evaluate();
            AssertEvaluationFailed(after, "expected _sample.Bool would be false" + Environment.NewLine + " but was true.");
        }
    }
}
